import { Injectable } from '@angular/core';
import {Order} from '../../model/order';
import {Base} from '../../model/base.enum';
import {Headers, Http} from '@angular/http';
import 'rxjs/add/operator/toPromise';

@Injectable()
export class OrderService {
  private orderUrl = Base.baseUrl + '/admin/order';

  constructor(private http: Http) { }

  getOrders(page: number): Promise<Order[]> {
    return this.http.get(this.orderUrl + '/list').toPromise().then(response => response.json().data as Order[]);
  }
  // getNewId(): Promise<string> {
  //   return this.http.get(this.orderUrl + '/getNewId').toPromise().then(response => response.json().data as string);
  // }
  // insertOrder(order: Order): void {
  //   this.http.post(this.orderUrl + '/insert', JSON.stringify(order)).toPromise().then(res => res.json().data as Order);
  // }

}
